package io.renren.modules.upk.controller;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.upk.entity.UpkSmscodeEntity;
import io.renren.modules.upk.service.UpkSmscodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;
/**
 * 短信验证码表，保存短信验证码。
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-29 20:29:24
 */
@RestController
//@RequestMapping("generator/upksmscode")
public class UpkSmscodeController {
    @Autowired
    private UpkSmscodeService upkSmscodeService;
    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("upk:upksmscode:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = upkSmscodeService.queryPage(params);
        return R.ok().put("page", page);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("upk:upksmscode:info")
    public R info(@PathVariable("id") Long id){
			UpkSmscodeEntity upkSmscode = upkSmscodeService.selectById(id);
        return R.ok().put("upkSmscode", upkSmscode);
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("upk:upksmscode:save")
    public R save(@RequestBody UpkSmscodeEntity upkSmscode){
			upkSmscodeService.insert(upkSmscode);
        return R.ok();
    }
    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("upk:upksmscode:update")
    public R update(@RequestBody UpkSmscodeEntity upkSmscode){
			upkSmscodeService.updateById(upkSmscode);
        return R.ok();
    }
    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("upk:upksmscode:delete")
    public R delete(@RequestBody Long[] ids){
			upkSmscodeService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}
